package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    @PostMapping("/saveUser")
    public void saveUser(@RequestBody User user){
        userService.saveUser(user);
    }

    @PutMapping("/updateUserById")
    public void updateUserById(@RequestBody User user){
        userService.updateUserById(user);
    }

    @DeleteMapping("/deleteUserById")
    public void deleteUserById(User user){
        userService.deleteUserById(user);
    }

    @GetMapping("/findUser")
    public List<User>findUser(User user){
        return userService.findUser(user);
    }
}
